package top.xierongsheng.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.xierongsheng.user.dao.RoleResourceMapper;
import top.xierongsheng.user.model.SysRoleResource;
import top.xierongsheng.user.service.IRoleResourceService;

import java.util.HashMap;
import java.util.List;

/**
 * 角色资源表 服务实现类
 *
 * @auther 谢荣生
 * @datetime 2020/10/16 17:23
 */
@Service
public class RoleResourceServiceImpl extends ServiceImpl<RoleResourceMapper, SysRoleResource> implements IRoleResourceService {

    @Autowired(required = false)
    private RoleResourceMapper roleResourceMapper;


    /**
     * 根据角色id获取用户权限菜单
     *
     * @param roleId
     * @return
     * @auther 谢荣生
     * @datetime 2020/11/2 17:34
     */
    @Override
    public List<HashMap> getMenuByRoleId(String roleId) {
        return roleResourceMapper.getMenuByRoleId(roleId);
    }

    /**
     * 根据角色id与资源id删除权限
     *
     * @param roleId
     * @param resourceId
     * @return
     * @auther 谢荣生
     * @datetime 2020/11/5 16:42
     */
    @Override
    public boolean delPermission(String roleId, String resourceId) {
        return roleResourceMapper.delPermission(roleId, resourceId);
    }
}
